global root "/Volumes/Workgroup/Lab/Lab-heimb/Montenovo/Volunteering Paper/Data"
global output_data "$root/06_yearly_analytic_files/first_dollar"
global dictionaries "$root/Dictionaries"


cd "$dictionaries"

capture log close
log using 02_Preliminary_Regressions_append, replace

cd "$output_data"

clear
local filelist : dir "$output_data" files "fd_analytic_file_foryear_*.dta"
foreach file of local filelist {
append using `file'
}

label var unique_id_crossys "Unique ID individual"
label var taxprice 			"Tax Price"
label var taxable_inc_hh_gen "HH Income"
label var married 		 "Married"
label var sex 		 "Sex"
label var LHS				 "Less than High School"
label var HS			 "High School"
label var some_college		  "Some College"
label var college_grad		  "College"
label var college_plus		  "College+"
label var white			  "White"
label var black			  "Black"
label var native_amer	  "Native"
label var asian		  "Asian"
label var other			 "Other race"
label var hispanic	  "Hispanic"
label var children			  "N. Children"
label var age 				"Age"
label var post_tax_income "Post Tax Income"
label var whether_volunteer_person "Whether Volunteered" 
label var hours_volunteer_person "Hours Volunteered" 
label var hourly_wage_aftertax "Net Hourly Wage"
label var full_time "Full Time"
label var rural "Rural"
label var religion "Religion"
//label var sex_spouse	"Sex - Spouse"

sort  unique_id_crossys year
order  unique_id_crossys year

replace religion=0 if (religion ==0|religion ==1 |religion ==2 | religion ==3 | religion>31 ) & year==2018
replace religion=0 if (religion ==0| religion>31)  & year!=2018
replace religion=1 if religion>1

bysort unique_id_crossys: egen min_year=min(year)
gen white_min_year=white if year==min_year
gen black_min_year=black if year==min_year
gen native_amer_min_year=native_amer if year==min_year
gen asian_min_year=asian if year==min_year
gen other_min_year=other if year==min_year
gen hispanic_min_year=hispanic if year==min_year
gen sex_min_year=sex if year==min_year

drop white black native_amer asian other hispanic sex

bysort unique_id_crossys: egen white=max(white_min_year)
bysort unique_id_crossys: egen black=max(black_min_year)
bysort unique_id_crossys: egen native_amer=max(native_amer_min_year)
bysort unique_id_crossys: egen asian=max(asian_min_year)
bysort unique_id_crossys: egen other=max(other_min_year)
bysort unique_id_crossys: egen hispanic=max(hispanic_min_year)
bysort unique_id_crossys: egen sex=max(sex_min_year)


replace taxprice=0 if taxprice<0
replace rural=0 if rural==99

 foreach var of varlist  hourly_wage_aftertax post_tax_income taxable_inc_hh_gen {
 	
	replace `var'=(`var'*243.558499935398)/165.1732 if year==2000
	replace `var'=(`var'*243.558499935398)/175.9097 if year==2002
	replace `var'=(`var'*243.558499935398)/182.8035 if year==2004
	replace `var'=(`var'*243.558499935398)/214.13276435707 if year==2010
	replace `var'=(`var'*243.558499935398)/236.966866614782 if year==2016
	
 }

cd "$root"
save fd_appended_analytic_010305111719.dta, replace

log close
